package com.baizhi.controller;


import com.baizhi.entity.Product;
import com.baizhi.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengg
 * @since 2021-02-07
 */
@RestController
public class ProductController {
    @Autowired
    private ProductService ps;
    @GetMapping("products")
    public List<Product> selectAll(){
        return ps.list();
    }
    @GetMapping("products/{id}")
    public Product selectOne(@PathVariable("id")int id){
        return ps.getById(id);
    }
}
